// 分类的store
import { fetchCategory } from '@/api/layout'
const category = {
  namespaced: true,
  state: {
    categoryList: []
  },
  mutations: {
    setCategoryList (state, list) {
      state.categoryList = list
    }
  },
  actions: {
    async fetchCategoryList ({ commit }) {
      // 1. 调用接口获取分类数据
      const res = await fetchCategory()
      // 2. 提交mutation存入vuex
      commit('setCategoryList', res.result)
    }
  }
}

export default category

// 选择合适的地方 action调用起来？
